package com.zxbit.flash.bean;

import android.os.Parcel;
import android.os.Parcelable;

import com.zxbit.flash.utils.DebugLog;

public class ProductItemData implements Parcelable, Comparable<ProductItemData>{
    private static final String TAG = ProductItemData.class.getSimpleName();


    /**
     * pId : 1
     * pRange : 200
     * pTerm : 7
     */

    private String pId;
    private String pRange;
    private String pTerm;
    //目前只展示2的
    private String lendStatus;

    protected ProductItemData(Parcel in) {
        pId = in.readString();
        pRange = in.readString();
        pTerm = in.readString();
        lendStatus = in.readString();
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(pId);
        dest.writeString(pRange);
        dest.writeString(pTerm);
        dest.writeString(lendStatus);
    }

    @Override
    public int describeContents() {
        return 0;
    }

    public static final Creator<ProductItemData> CREATOR = new Creator<ProductItemData>() {
        @Override
        public ProductItemData createFromParcel(Parcel in) {
            return new ProductItemData(in);
        }

        @Override
        public ProductItemData[] newArray(int size) {
            return new ProductItemData[size];
        }
    };

    public String getPId() {
        return pId;
    }

    public void setPId(String pId) {
        this.pId = pId;
    }

    public int getPRange() {
        int intRange = -1;
        try {
            intRange = Integer.parseInt(pRange);
        } catch (NumberFormatException e) {
            DebugLog.e(TAG, "NumberFormatException pRange's value is:" + pRange == null ? "null"
                    : pRange);
        }
        return intRange;
    }

    public void setPRange(String pRange) {
        this.pRange = pRange;
    }

    public String getPTerm() {
        return pTerm;
    }

    public void setPTerm(String pTerm) {
        this.pTerm = pTerm;
    }

    public String getLendStatus() {
        return lendStatus;
    }

    public void setLendStatus(String lendStatus) {
        this.lendStatus = lendStatus;
    }

    @Override
    public int compareTo(ProductItemData arg0) {
        try {
            return Integer.valueOf(this.getPTerm()) - Integer.valueOf(arg0.getPTerm());
        } catch (Exception e) {
            e.printStackTrace();
            return 1;
        }
    }
}
